﻿define(["jQuery", "kendo", "config", "utils", "localdata"],
        function ($, kendo, config, utils, localdata) {

            //private functions
            var _handleRedirection = function () {
                console.log('entering: viewModel.index._handleRedirection');
                //alert('inside init');
                if (localdata.localRegistrationFound) {
                    //user device is registered

                    if (localdata.isMultipleType) {
                        //has multiple, so give him the screen to select
                        utils.navigate("../views/moduleselection.html");
                    }
                    else {
                        //user is registered and has one module, direct him to the right one
                        switch (localdata.usermainmodule) {
                            case "passenger":
                                utils.navigate("../views/passengermain.html");
                                break;
                            case "driver":
                                utils.navigate("../views/drivermain.html");
                                break;
                            case "company":
                                utils.navigate("../views/companymain.html");
                                break;
                        }
                    }
                }
                else {
                    //user device is not registered....
                    utils.navigate("views/firsttime.html");
                }
            }

            /*RETURN*/
            return {

                //init
                init: function (initEvent) {
                    console.log('entering: viewModel.firsttime.init');
                },

                //show
                show: function () {
                    console.log('entering: viewModel.firsttime.init');
                },

                //driverclick
                driverclick: function () {
                    console.log('entering: viewModel.firsttime.driverclick');
                    utils.navigate(config.paths.driverRegistration);
                },
                passengerclick: function () {
                    console.log('entering: viewModel.firsttime.passengerclick');
                    utils.navigate("views/passengerRegistration.html");
                }
                

            }
        });